//
//  SecondeViewController.m
//  Four_years
//
//  Created by 中软国际019 on 15/11/9.
//  Copyright © 2015年 中软三班四年小组. All rights reserved.
//

#import "SecondeViewController.h"
#import "sheZhi.h"
#import "MyeTableViewCell.h"

@interface SecondeViewController (){
    UITableView *_tableView;
    NSMutableArray *tableViewArray;
}

@end

@implementation SecondeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor=[UIColor whiteColor];
    
    _tableView=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    _tableView.dataSource=self;
    _tableView.delegate=self;
    [self.view addSubview:_tableView];
    [self initData];
    UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(WIDTH/2-75, HEIGHT/3*2, 150, 50)];
    button.backgroundColor=[UIColor colorWithRed:62/255.0 green:193/255.0 blue:209/255.0 alpha:1];
    [button setTitle:@"退  出  账  号" forState:UIControlStateNormal];
    [_tableView addSubview:button];

}
//初始化数据
-(void)initData{
    sheZhi *s1=[[sheZhi alloc]initWithSheZhi:@"修改密码"];
    sheZhi *s2=[[sheZhi alloc]initWithSheZhi:@"修改登录手机号"];
    NSArray *arr1=@[s1,s2];
    
    sheZhi *s3=[[sheZhi alloc]initWithSheZhi:@"开启声音提醒"];
    sheZhi *s4=[[sheZhi alloc]initWithSheZhi:@"开启震动提醒"];
    NSArray *arr2=@[s3,s4];
    
    tableViewArray=[NSMutableArray arrayWithObjects:arr1,arr2, nil];
    
    
}
//设置表头名字
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    if (section==0) {
        return @"账号设置";
    }else
    {
        return @"系统设置";
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return tableViewArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    NSArray  *g=tableViewArray[section];
    return g.count;
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *name=@"cell";
    MyeTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:name];
    if (cell==nil) {
        cell=[[MyeTableViewCell alloc]init];
        
        
    }
    NSArray *g=tableViewArray[indexPath.section];
        sheZhi *x=g[indexPath.row];
    
        cell.label.text=x.sheZhi;
    if (indexPath.section==1) {
        UISwitch *s = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
        s.on=YES;
        [cell.mySwitch addSubview:s];
        
    }
        cell.accessoryType=UITableViewCellAccessoryNone;
    return cell;
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
